package com.vint.mi;

/**
 * 数字转汉字
 */
public class Mi17 {
    public static String[] character = {"零","壹","贰","参","肆","伍","陆","柒","捌","玖","拾","佰","仟","万","亿","整"};
    public static String solution(String line){
        StringBuffer sb = new StringBuffer();
        for(int i=line.length()-1; i>=0;i = i-4){
            if(i-4>=0) {
                int v = Integer.parseInt(line.substring(i-4,i));
                
            }
        }
        return sb.toString();
    }

    //src==0未考虑
    public static String changeCharFour(int src){
        StringBuffer sb = new StringBuffer();
        if(src%1000==0){
            return sb.append(character[src/1000]).append(character[12]).toString();
        }
        if(src%100==0){
            return sb.append(character[src/100]).append(character[11]).toString();
        }
        int v1 = src / 1000;
        src = src % 1000;
        int v2 = src /100;
        src = src % 100;
        int v3 = src /10;
        src = src % 10;
        if(v1!=0){
           sb.append(character[v1]).append(character[12]);
        }
        if(v2!=0){
            sb.append(character[v2]).append(character[11]);
        }else{
           if(v1!=0){
               sb.append(character[0]);
           }
        }

        if(v3!=0){
            sb.append(character[v3]).append(character[10]);
        }else{
            if(v2!=0) {
                sb.append(character[0]);
            }
        }
        if(src!=0){
            sb.append(character[src]);
        }
        return sb.toString();

    }
    public static void main(String[] args) {
        System.out.println(changeCharFour(1356));
        System.out.println(changeCharFour(2094));
        System.out.println(changeCharFour(78));
        System.out.println(changeCharFour(300));
        System.out.println(changeCharFour(60));
        System.out.println(changeCharFour(9));
        System.out.println(changeCharFour(908));
        System.out.println(changeCharFour(9000));

    }
}
